#include "Sprite.h"

Sprite::Sprite()
{
	flags = 1;
}

Sprite::Sprite(int id)
{
	flags = 1;
	TextureId = id;
}

bool Sprite::IntersectsWith(Sprite* t)
{
	bool ix = false, iy = false;
	if (x > t->x)
	{
		if (x - HitBoxW / 2 < t->x + t->HitBoxW / 2) ix = true;
	}
	else
	{
		if (x + HitBoxW / 2 > t->x - t->HitBoxW / 2) ix = true;
	}
	if (y > t->y)
	{
		if (y - HitBoxH / 2 < t->y + t->HitBoxH / 2) iy = true;
	}
	else
	{
		if (y + HitBoxH / 2 > t->y - t->HitBoxH / 2) iy = true;
	}
	return ix && iy;
}

float Sprite::DistanceFrom(Sprite* t)
{
	return sqrt((x - t->x)*(x - t->x) + (y - t->y)*(y - t->y));
}

float Sprite::DistanceFrom(D3DXVECTOR2 t)
{
	return sqrt((x - t.x)*(x - t.x) + (y - t.y)*(y - t.y));
}